#ifndef _BIITypes_h
#define _BIITypes_h

#include "BIIDefines.h"

#include "Debg.h"

typedef struct {
	unsigned long	id;					//Template Id number
	unsigned long	employee_id;		// Optional Employee Id
	unsigned long	password;			//Optional administration pass

	unsigned char	sensor_version;		//specifies sensor type/version (Do not alter)
	unsigned char	template_version;	//Specifieds tempalte version (Do not alter)
	char			name[16];			//optional name
	unsigned char	finger;				//finger enrolled (0-9 is leftypinky to right pinky)
	unsigned char	admin_level;		//Administration Privleges
	unsigned char	schedule;			//Optional template use schedule (not implemented)
	unsigned char	security_thresh;	//Template specific security level

	unsigned char	noise_level[18];	//Noise Level (DO NOT ALTER VALUE)
	unsigned char	corramb[NUM_CORE];	//Core Stats (DO NOT ALTER VALUE)			
	unsigned char	ihcore[NUM_CORE];	//Horizontal core locations (DO NOT ALTER VALUE)		
	unsigned char	ivcore[NUM_CORE];	//Veritical core locations (DO NOT ALTER VALUE)
	unsigned char	temp_xoffset;		//(DO NOT ALTER VALUE)
	unsigned char	temp_yoffset;		//(DO NOT ALTER VALUE)
	unsigned char	index;				//Template Index (refers to a specific instance of an ID)
	unsigned char	inphase[PACKED_ARRAY_SIZE];	//Fingerprint data (DO NOT ALTER)
} BII_Template;

typedef struct {
	int nx_pix;							//number of x pixels
	int ny_pix;							//number of y pixels
	int bits_per_pixel;					//number of bits in each pixel (currently 8)
	unsigned char *p_image;	//Pointer to an unsigned character array of nx_pix pixels by ny_pix pixels */
} BII_Raw;

typedef struct {
	int nx_pix;							//number of x pixels
	int ny_pix;							//number of y pixels
	int bits_per_pixel;					//number of bits in each pixel (currently 8)
	unsigned char image[RAW_IMAGE_SIZE_X*RAW_IMAGE_SIZE_Y];
} BII_Full_Raw;

//BII_Template_Admin_Type supplants old non-convention name TemplateAdminType)
typedef struct {
	unsigned int ID;					//Id of a specific template
	int Index;							//That templates index
	int Admin_Level;					//Administration priveleges of that template
} BII_Template_Admin_Struct;

//BII_Wiegand_Type supplants old non-convention name WiegandType)
typedef struct {
	unsigned int Input_Wiegand_Format;	//Input format of wiegand string
	unsigned int Output_Wiegand_Format;	//Output Format of wiegand string
	unsigned int Output_Action;			//Ouput action options
	unsigned int Output_Fail_Code_0;	//Optional code to be sent on failed verification
	unsigned int Output_Fail_Code_1;	//Optional code to be sent on failed verification
	unsigned int Output_Site_Code;		//Configuration bits specify how to build the site code
	unsigned int Output_Pulse_Width;	//Pulse with of wiegand string in microseconds
	unsigned int Output_Pulse_Interval;	//Pulse interval of wiegand string in microseconds.
} BII_Wiegand_Struct;

#define WiegandType BII_Wiegand_Struct //For backwards compatabillity only (If name WiegandType conflict remove this macro)
#define TemplateAdminType BII_Template_Admin_Struct //For backwards compatabillity only (If name TemplateAdminType conflict remove this macro)



//Revision 1 sensor parameter structure
typedef struct {
	unsigned int discharge_time;		//Relevent to veridicom only
	unsigned int discharge_current;     //Relevent to veridicom only
	int			 sensor;
} BII_Sensor_Param;


typedef struct {
	char flowType;						//Type of Flow Control (See BIIDefines.h)
	char flowDir;						//Flow Control Direction (See BIIDefines.h)
	char transmitOn;					//Value indicating Transmit On
	char transmitOff;					//Value indicating Transmit Off
} BII_Flow_Control_Struct;


typedef struct {
	unsigned int state[12];				//See BIIDefines.h for valid states
} BII_LED_State_Table;					

typedef struct {
	BII_LED_State_Table group[13];		//See BIIDefines.h for valid groups
} BII_LED_Table;

typedef struct {
	int host;
	int aux;
	int wiegand;
	int line_trigger;
	int reserved2;
} BII_Verify_Response_Struct;

typedef struct {
	int auxState;
	int auxPassword;
	int wiegandState;
	int wiegandRes;
	int reserved1;
	int reserved2;
	int reserved3;
	int reserved4;
} BII_Port_Enable_Struct;


//For Veridicom Sensors only
typedef struct {
	int dischargTime;
	int dischargeCurrent;
	int signal;
} BII_Calibrate_Res;


typedef struct {
	int				totalLength;
	int				bitFormat;	
	int				idStartBit;
	int				idLength;
	int				siteStartBit;
	int				siteLength;
	int				parityType;	  // How to calculate parity
	unsigned int 	parityFlags;  // Under what conditions to calculate parity (bit 0 - parity check on input?)
	int				evenParityBit;
	int				oddParityBitTwo;
	int				evenParityBitTwo;
	int				oddParityBit;
	unsigned int	defOutPulseWidth; //recommended default
	unsigned int	defOutPulseInterval; //recommend default
	unsigned int	reserved_1;
	unsigned int	reserved_2;
	unsigned int	reserved_3;
	unsigned int	reserved_4;
} BII_Wiegand_Format;  

typedef struct {
	unsigned int comparison;
	unsigned int product;
	unsigned int reserved2;
} BII_Unit_Type; 

typedef struct {
	unsigned int currentState;
	unsigned int storedState;
	unsigned int reserved1;
	unsigned int reserved2;
} BII_AUTO_FDETECT; 


typedef struct
{
	unsigned int ID_1;
	unsigned int Type_1;
	unsigned int ID_2;
	unsigned int Type_2;
	unsigned int ID_3;
	unsigned int Type_3;
	unsigned int ID_4;
	unsigned int Type_4;
}BII_Wiegand_ID_List;

typedef struct {
	unsigned int Key;
	unsigned int Mode;
	unsigned int Finger_Detect;
	unsigned int Search_Range;
	unsigned int Type;
	unsigned int Res_1;
} Product_Type_Struct;

typedef struct
{
	unsigned int GPI0_Current_State;
	unsigned int GPI1_Current_State;
	unsigned int GPI0_Latched_State;
	unsigned int GPI1_Latched_State;
	unsigned int reserved0;
	unsigned int reserved1;
}BII_GPI_States;

typedef struct
{
	unsigned int GPO0_State;
	unsigned int reserved0;
	unsigned int reserved1;
	unsigned int reserved2;
	unsigned int GPO1_State;
	unsigned int reserved3;
	unsigned int reserved4;
	unsigned int reserved5;
}BII_Default_GPO_States;

typedef struct
{
	unsigned int Line;
	unsigned int State;
	unsigned int Duration;
	unsigned int reserved0;
	unsigned int reserved1;
	unsigned int reserved2;
}BII_GPO_State;

typedef struct
{
	unsigned int Line;
	unsigned int reserved0;
	unsigned int reserved1;
}BII_Reset_GPO_Struct;

typedef struct
{
	unsigned int GPO0_State;
	unsigned int GPO1_State;
	unsigned int reserved0;
	unsigned int reserved1;
}BII_GPO_State_All;

typedef struct
{
	unsigned int password;
	char SerialNumber[80];
}BII_SetSerialNumber_Struct;

typedef struct
{
	char SerialNumber[80];
}BII_GetSerialNumber_Struct;

typedef	unsigned char BioAPI_BIR_VERSION;
typedef	unsigned char BioAPI_BIR_DATA_TYPE;
typedef	signed   char BioAPI_QUAILTY;
typedef	unsigned char BioAPI_BIR_PURPOSE;
typedef	unsigned long BioAPI_BIR_AUTH_FACTORS;

typedef struct
{
	unsigned long			ulLength;
	BioAPI_BIR_VERSION		HeaderVersion;;
	BioAPI_BIR_DATA_TYPE	Type;
	WORD					uhwFormatOwner;
	WORD					uhwFormatID;
	BioAPI_QUAILTY			Quality;
	BioAPI_BIR_PURPOSE		Purpose;
	BioAPI_BIR_AUTH_FACTORS	FactorsMask;

}BII_tagBio_API_BIR_Header;

/* New struct for ESI Smartcard Layouts */

typedef struct
{
	unsigned int BlockType[48];
}BII_Smartcard_Layout_Struct;

typedef struct
{
	unsigned char PageUse[16];
}BII_IClass_Layout_Struct;

typedef struct
{
	unsigned int numApplicationAreas;
	unsigned int pageLength;
	unsigned int lockedAppAreas;
	unsigned int fuseValue;
}BII_IClass_Smartcard_Info;

typedef struct
{
	unsigned char serialNumber[8];
}BII_Smartcard_Manufacturer_Info;

typedef struct
{
	unsigned int	action;				//verification action
	unsigned int	id;					//Template Id number
	unsigned int	index;				//Template Index (refers to a specific instance of an ID)
	unsigned int	quality;			//enroll quality
	unsigned int	content;			//enroll content
	unsigned int	score;				//verification score
	unsigned char	wiegandID[8];		//Wiegand ID		
}BII_Verification_Queue_Entry;

typedef struct
{
	unsigned int	id;
	unsigned char	reserved_1;
	unsigned char	index;
	unsigned short	year;
	unsigned char	month;
	unsigned char	day;
	unsigned char	hour;
	unsigned char	min;
	unsigned char	sec;
	unsigned char	trans_code;
	unsigned char	flag_port;
	unsigned char	trans_log_data_1;
	unsigned char	trans_log_data_2;
	unsigned char	trans_log_data_3;
	unsigned char	reserved_2; 
	unsigned char	status; 
}BII_Transaction_Log_Struct;

typedef enum 
{ 
	TL_SYSTEM_BOOT 				= 0x00, 
	TL_PROGRAM_FIRMWARE			= 0x01,
	TL_REBOOT_INITIATED			= 0x02,	
	TL_READ_TRANSACTION_LOG		= 0x08,
	TL_ERASE_TRANSACTION_LOG	= 0x09,
	TL_GET_NUM_TRANSACTION_LOG	= 0x0A,
	TL_ENROLL_STORE				= 0x10,
	TL_ENROLL_TRANSFER			= 0x11,
	TL_ENROLL_TRANSFER_SEARCH 	= 0x12,
	TL_DELETE_TEMPLATE			= 0x18,
	TL_ADD_TEMPLATE				= 0x19,
	TL_EDIT_TEMPLATE			= 0x1A,
	TL_VERIFY_ID				= 0x30,
	TL_VERIFY_TEMPLATE			= 0x31,
	TL_VERIFY_PASSTHROUGH		= 0x32,
	TL_VERIFY_DURESS_ID         = 0x33,
	TL_VERIFY_DURESS_TEMPLATE   = 0x34,
	TL_IDENTIFY					= 0x38,
	TL_IDENTIFY_DURESS			= 0x39,
	TL_GREEN_LED				= 0x40,
	TL_RED_LED					= 0x41,
	TL_AMBER_LED				= 0x42,
	TL_LINE3					= 0x43
} BII_TransactionLog_Types;

// DateTime Struct for V-Station
typedef struct
{
	unsigned short	year;
	unsigned char	month;
	unsigned char	day;
	unsigned char	hour;
	unsigned char	min;
	unsigned char	sec;
}BII_DateTime_Struct;

// defines for V-Station Transaction Log Struct...
typedef enum 
{ 
	MV12_HOST = 0,
	MV12_AUX, 
	MV12_WIEGAND, 
	MV12_LED, 
	MV12_WIEGAND_LED,
	MV12_GPI0,
	MV12_GPO0, 
    MV12_GPI1,
	MV12_GPO1,
	MV12_MEZZANINE,
	VSTAT_KEYPAD,
    VSTAT_ENET,
	MV12_GPI0_1,
	NUM_IO_CHANNELS
} BII_MV12Channels;

// DateTime Settings Struct for V-Station
typedef struct
{
	unsigned int	twentyFourHourFormat;
	unsigned int	observeDaylightSavings;
	unsigned int	timeFormat;
	unsigned int	dateFormat;
	int				GMTDifferential;
	unsigned int	reserved_one;
	unsigned int	reserved_two;
	unsigned int	reserved_three;
}BII_DateTimeSettings_Struct;

// Extended ID Struct
typedef struct
{
	unsigned int	ID;					// 32 bit template ID
	unsigned char	ExtendedID[8];		// 64 bit extended ID
	unsigned char	Index;				// Template index
	unsigned char	Admin_Level;		// Administration priveleges of template
	unsigned char	reserved1;			// reserved
	unsigned char	reserved2;			// reserved
} BII_Ext_Template_Admin_Struct;


typedef enum
{
	GPO_NO_ACTION = 0,
	GPO_ENROLL_COMPLETED,
	GPO_ENROLL_INITIATED,
	GPO_VERIFY_PASSED,
	GPO_VERIFY_FAILED,
	GPO_FINGER_NOT_DETECTED,
	GPO_VSTATION_ADMIN_MODE,
	GPO_VSTATION_ENROLL_MODE,
	GPO_DELETE_ATTEMPTED,
	GPO_BOOTUP,
	GPO_NUM_ACTIONS
} BII_GPO_Actions;

typedef struct
{
	unsigned int GPO_0_Action;
	unsigned int GPO_1_Action;
	unsigned int GPO_0_AND_1_Action;
	unsigned int reserved_1;
	unsigned int reserved_2;
	unsigned int reserved_3;
} BII_GPO_Table;

typedef struct
{
	unsigned int GPI_0_Action;
	unsigned int GPI_1_Action;
	unsigned int GPI_0_AND_1_Action;
	unsigned int reserved_1;
	unsigned int reserved_2;
	unsigned int reserved_3;
} BII_GPI_Table;

typedef enum
{
	GPI_NO_ACTION = 0,
	GPI_VERIFY,
	GPI_SEARCH,
	GPI_ENROLL,
	GPI_DELETE,
	GPI_REBOOT,
	GPI_NUM_ACTIONS
} BII_GPI_Actions;

typedef struct
{
	unsigned char year;
	unsigned char month;
	unsigned char day;
	unsigned char reserved;
	unsigned int  schedule;
} BII_Holiday_Schedule_Struct;

#endif
